package org.infodavid.common.scheduler.impl.commands;

import org.joda.time.DateTime;

import org.infodavid.common.scheduler.commands.IScheduledCommand;
import org.infodavid.common.util.IVisitor;

/**
 * The Class SchedulerCommandImpl.
 */
public class SchedulerCommandImpl implements IScheduledCommand {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 8561379036960115642L;

	/** The expiration date. */
	private DateTime expirationDate = null;

	/** The key. */
	private String key = null;

	/** The processor class. */
	private Class<? extends IVisitor<? extends IScheduledCommand,? extends Object>> processorClass =
	    null;

	private boolean recoveryEnabled = true;

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.scheduler.commands.IScheduledCommand#getExpirationDate()
	 */
	public DateTime getExpirationDate() {
		return expirationDate;
	}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.scheduler.commands.IScheduledCommand#getKey()
	 */
	public String getKey() {
		return key;
	}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.scheduler.commands.IScheduledCommand#getProcessorClass()
	 */
	public Class<? extends IVisitor<? extends IScheduledCommand,? extends Object>> getProcessorClass() {
		return processorClass;
	}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.scheduler.commands.IScheduledCommand#isRecoveryEnabled()
	 */
	public boolean isRecoveryEnabled() {
		return recoveryEnabled;
	}

	/*
	 * (non-Javadoc)
	 * @see
	 * org.infodavid.common.scheduler.commands.IScheduledCommand#setExpirationDate(org.joda.time.DateTime
	 * )
	 */
	public void setExpirationDate(final DateTime value) {
		expirationDate = value;
	}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.scheduler.commands.IScheduledCommand#setKey(java.lang.String)
	 */
	public void setKey(final String value) {
		key = value;
	}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.scheduler.commands.IScheduledCommand#setProcessorClass(java.lang.Class)
	 */
	public void setProcessorClass(
	    final Class<? extends IVisitor<? extends IScheduledCommand,? extends Object>> value) {
		processorClass = value;
	}

	/*
	 * (non-Javadoc)
	 * @see org.infodavid.common.scheduler.commands.IScheduledCommand#setRecoveryEnabled(boolean)
	 */
	public void setRecoveryEnabled(final boolean flag) {
		recoveryEnabled = flag;
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		final StringBuilder builder = new StringBuilder();

		builder.append(super.toString());
		builder.append(" [processorClass=");
		builder.append(processorClass);
		builder.append(", key=");
		builder.append(key);
		builder.append(", expirationDate=");
		builder.append(expirationDate);
		builder.append(", recoveryEnabled=");
		builder.append(recoveryEnabled);
		builder.append("]");

		return builder.toString();
	}
}
